package com.shujia.java.day19.demo2;

public class Test {
    public static void main(String[] args) {
        // 通过Thread来实现多线程
        // 通过创建类实例来实现多线程,没创建一个实例，int sum就定义一次
        // 每个线程都是他自己的0-99个
//        MyThread myThread = new MyThread();
//        MyThread myThread1 = new MyThread();
//        MyThread myThread2 = new MyThread();
//
//        myThread.start();
//        myThread1.start();
//        myThread2.start();

        //通过Runnable来实现多线程
        //类实例创建一次 int sum就定义一次
        //下面的线程就公用一个sum
        MyRunnable myRunnable = new MyRunnable();

        Thread thread = new Thread(myRunnable);
        Thread thread1 = new Thread(myRunnable);
        Thread thread2 = new Thread(myRunnable);

        thread.start();
        thread1.start();
        thread2.start();


    }
}
